'''
Author: your name
Date: 2020-11-06 14:04:53
LastEditTime: 2020-11-06 14:21:37
LastEditors: Please set LastEditors
Description: In User Settings Edit
FilePath: \python-study\djangoS\app01\app01\Views\Book\bookExculd.py
'''
from django.shortcuts import render, HttpResponse
from Models.models import Book
from django.core import serializers


class bookExculd():
    def index(request):
        # 排除不符合条件的数据
        books = Book.objects.exclude(pk=5)
        print(serializers.serialize('json', books))
        print("//////////////////////////////////////")
        books = Book.objects.exclude(publish='菜鸟出版社', price=300)
        print(books, type(books))  # QuerySet类型，类似于list。
        return HttpResponse(serializers.serialize('json',books))